[HEADER]
	VERSION		01.00.00.00
	DESCRIPTION texture example
	COPYRIGHT	Img Tec
[/HEADER]

[TEXTURES] 
	FILE basetex 	Basetex.pvr		LINEAR-LINEAR-LINEAR
	FILE reflection Reflection.pvr	LINEAR-LINEAR-LINEAR
[/TEXTURES]

[VERTEXSHADER]
	NAME 		VertexShader

	// LOAD GLSL AS CODE
	[GLSL_CODE]
		attribute highp   vec4  inVertex;
		attribute mediump vec3  inNormal;
		attribute mediump vec2  inTexCoord;

		uniform highp   mat4  WVPMatrix;
		uniform mediump mat3  WorldViewIT;
		uniform mediump vec3  LightDirection;

		varying lowp    float  DiffuseIntensity;
		varying mediump vec2   TexCoord;
		varying mediump vec2   EnvMapCoord;

		void main()
		{
			gl_Position = WVPMatrix * inVertex;
			mediump vec3 transNormal = normalize(WorldViewIT * inNormal);
			DiffuseIntensity = 0.5 + dot(transNormal, normalize(LightDirection)) * 0.5;
			TexCoord = inTexCoord;
			EnvMapCoord = 0.5 + transNormal.xy * 0.5;
		}
	[/GLSL_CODE]
[/VERTEXSHADER]
    
[FRAGMENTSHADER] 
	NAME 		FragmentShader 

	// LOAD GLSL AS CODE
	[GLSL_CODE]
		uniform sampler2D  sBaseTex;
		uniform sampler2D  sEnvMap;
		
		varying lowp    float  DiffuseIntensity;
		varying mediump vec2   TexCoord;
		varying mediump vec2   EnvMapCoord;

		void main()
		{
			lowp vec3 envColor = 0.5 * texture2D(sEnvMap, EnvMapCoord).rgb;
			gl_FragColor.rgb = texture2D(sBaseTex, TexCoord).rgb * (DiffuseIntensity + envColor);
			gl_FragColor.a = 1.0;
		}
	[/GLSL_CODE]
[/FRAGMENTSHADER]
 
[EFFECT] 
	NAME 	Effect
		
	// GLOBALS UNIFORMS
	UNIFORM WorldViewIT 		WORLDVIEWIT
	UNIFORM WVPMatrix 			WORLDVIEWPROJECTION
	UNIFORM	LightDirection		LIGHTDIREYE
	UNIFORM	sBaseTex			TEXTURE0
	UNIFORM	sEnvMap				TEXTURE1

	// ATTRIBUTES
	ATTRIBUTE 	inVertex	POSITION
	ATTRIBUTE	inNormal	NORMAL
	ATTRIBUTE	inTexCoord	UV

	VERTEXSHADER   VertexShader
	FRAGMENTSHADER FragmentShader
	TEXTURE 0 basetex
	TEXTURE 1 reflection
[/EFFECT]
